	   $(document).ready(function(){
		   $(".top_header_wrap").load("../common/header.html")
		   $(".footer_container").load("../common/footer.html")
	   })
	   // 获取url地址参数
	   function getQueryVariable(variable)
{
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
			   console.log(pair)
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
}
	   var idx = getQueryVariable("idx")
	   var sch_name = decodeURIComponent(getQueryVariable("sch_name"))
	   var fid = getQueryVariable("fid")
	   console.log(idx,sch_name,fid)
	   // Vue
	   var app = new Vue({
	   	el:"#app",
		data:{
			// url地址参数
			sch_type : idx,
			sch_name : sch_name,
			fid:fid,
			// 排行榜
			buzz:[],
			// 学校信息
			pageSize:3, //页面显示数据
			currPage:1 ,//第几页
			school_address:"",
			school_contact:"",
			school_icon:"",
			school_mark:"",
			sc_ma:"普通院校",
			school_name:"",
			school_rank:"",
		    school_id:"",
			// 父子评论信息
			head_pho:"",
			fa_nick:"",
			fa_time:"",
			fa_text:"",
			fa_zan:"",
			fa_froid:"",
			fa_userid:"",
			chillist:[],
			// 举报
			inform1 : true,
			inform2 : true,
			info_inde:"yi",
			// 举报理由
			reported:false,
		},
		methods:{
			   // 获取排行榜
			   getrank:function(){
			   var _this = this
			   var sch_type = _this.sch_type
				   $.ajax({
					   url:host+"discussbar/hot_coments/"+sch_type,
					   success:function(res){
						   console.log(res)
						   _this.buzz = res.data
					   }
				   })
			   },			
              // 获取学校信息和帖子信息
			   getmess:function(){
				   var _this = this
				   var sch_name = _this.sch_name
				   var pagesize = _this.pageSize
				   var currpage = _this.currPage
			       var sch_type = _this.sch_type
				   console.log(sch_type)
				   console.log(sch_name)
				   console.log(pagesize)
				   console.log(currpage)
				   $.ajax({
					   url:host+"discussbar/forum/list/"+sch_name+"/"+pagesize+"/"+currpage+"/"+sch_type,
					   success:function(res){
						   console.log(res)
						   if(res.data.pageBean == null){
							   console.log(res)
							   console.log(res.data.school.school_address)
							   _this.school_address = res.data.school.school_address,
							   _this.school_contact = res.data.school.school_contact,
							   _this.school_icon = res.data.school.school_icon,
							   _this.school_name = res.data.school.school_name,
							   _this.school_rank = res.data.schoolRank,
							   _this.school_id = res.data.school.id
						   }else if(res.data.pageBean != null){
							   console.log(res)
							   _this.school_address = res.data.school.school_address,
							   _this.school_contact = res.data.school.school_contact,
							   _this.school_icon = res.data.school.school_icon,
							   _this.school_name = res.data.school.school_name,
							   _this.school_rank = res.data.schoolRank,
							   _this.school_id = res.data.school.id
							   _this.pagebean = res.data.pageBean.list
							   _this.forumid = res.data.pageBean.list
						   }
						   console.log(_this.school_name)
						   console.log(_this.school_rank)
						   console.log(_this.pagebean)
					   }
				   })
			   },
		      // 获取父级评论和子集评论
			  getfamily:function(){
				  // /forum/child/more/list/{forum_id}/{discussbar_type}
				  var _this = this
				  var fid = _this.fid
				  var idx = _this.sch_type
				  axios.get(host+"/discussbar/forum/child/more/list/"+fid+"/"+idx).then((res)=>{
					  console.log(res)
					  // 父评论信息
					  var fam = res.data.data
					  _this.head_pho = fam.forumesVO.user.head_photo //头像
					  _this.fa_nick = fam.forumesVO.user.nick //昵称
					  _this.fa_time = fam.forumesVO.user.regist_date //时间
					  _this.fa_text = fam.forumesVO.forum_content //内容
					  _this.fa_zan = fam.forumesVO.high_praise_counts //获赞数
					  _this.fa_froid = fam.forumesVO.id, //froumesid
					  _this.fa_userid = fam.forumesVO.user_id //用户id
					  // 子评论
					  _this.chillist = fam.childForumes //子评论列表
					  console.log(_this.chillist)
				  })
			  },
			   // 点赞
			   give_like:function(fid){
				   // /thumbsup/{froumid}/{discussbar_type}
				   // /discussbar/thumbsup/092efe9e778511e984a40c96e6d7103a/1
				   var _this = this
				   console.log(1)
				   console.log(fid)
				   var idx = _this.sch_type
				   axios.get(host+"discussbar/thumbsup/"+fid+"/"+idx).then((res)=>{
					   console.log(res)
					   if(res.data.status == 0){
						   _this.getfamily()
					   }else if(res.data.status != 0 ){
						   alert("网络异常")
					   }
				   })
			   },
		     // 激活举报按钮
			 activ1:function(){
				 var _this = this
				 _this.inform1 = false
				 setTimeout(function(){
					 _this.inform1 = true
				 },2000)
			 },
			 activ2:function(index){
				 var _this = this
				 console.log(index)
				 _this.info_inde = index
				 setTimeout(function(){
					 _this.info_inde = "yi"
				 },2000)
			 },
			   //打开举报信息
			   open:function(){
				   var _this = this
				   _this.reported = true
			   },
			   // 子评论打开举报信息
			   open2:function(fid,uid){
				   var _this = this
				   _this.reported = true
				    _this.fa_froid = fid
					_this.fa_userid = uid
					console.log(fid,uid)
			   },
			   // 关闭举报信息
			   close:function(){
				   var _this = this
				   _this.reported = false
			   },
			   // 调取举报接口
			   whistle:function(event){
				   var _this = this
				   var fid = _this.fa_froid
				   var uid = _this.fa_userid
				   var infor_type = event.target.dataset.rep
				   var idx = _this.sch_type
				   console.log("评论id："+fid)
				   console.log("用户id："+uid)
				   console.log("举报类型："+infor_type)
				   console.log("学校类型："+idx)
				   console.log("url地址："+host)
				   axios.get(host+"discussbar/Report/"+fid+"/"+infor_type+"/"+uid+"/"+idx).then((res)=>{
					   console.log(res)
					   if(res.data.data == "举报失败"){
						   alert("网络异常")
						   _this.reported = false
					   }else if(res.data.data == "举报成功"){
						   alert("举报成功")
						   _this.reported = false
					   }
				   })
			   },
		},
		created:function() {
			var _this = this
			_this.getmess()//获取学校信息
			_this.getrank()//获取排行榜
			_this.getfamily()//获取父子评论
			
		}
	  })